/**
行政区划显示组件

属性：
code:String 例如：150302
 */
<template>
  <span>{{ label }}</span>
</template>

<script>
export default {
  props: {
    code: String,
  },
  data() {
    return {
      label: "",
    };
  },
  watch: {
    code(val) {
      this.$api.post("/api/dict/list", "行政区划").then((data) => {
        const { success, result } = data;
        if (success) {
          if (result.total > 0) {
            let obj = result.rows.find(row=>row.code==val)
            if (typeof obj != "undefined") {
              this.label = obj.title;
            }
          }
        }
      });
    },
  },
};
</script>
